using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Come : MonoBehaviour
{
    public Vector3[] come;
    public GameObject[] Enemy;
    public GameObject EnemyCome_Eff;
    
    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    private void OnTriggerExit(Collider other)
    {
        if(other.tag=="Player")
        {
            for (int i = 0; i < Enemy.Length; i++)
            {
                if (Enemy[i] != null)
                {
                    CreatEnemy(Enemy[i], come[i]);
                }
            }

            Destroy(gameObject);
        }

    }
    void CreatEnemy(GameObject enemy, Vector3 Eenemytransforma)
    {
        GameObject E = Instantiate(enemy);
        GameObject F = Instantiate(EnemyCome_Eff);
        E.transform.position = Eenemytransforma;
        F.transform.position = Eenemytransforma;
        E.SetActive(true);
        E.GetComponent<CharacterController>().enabled = true;
        Destroy(F, 1.5f);
    }
}
